package com.sgj.factory.simplefactory.pizzastore.order;

import com.sgj.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.sgj.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.sgj.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * 简单工厂模式
 * @Author: Guoji Shen
 * @Date: 2021/11/11 15:40
 */
public class SimpleFactory {
    public static Pizza createPizza(String orderType) {
        Pizza pizza = null;
        // 使用简单工厂模式
        if (orderType.equalsIgnoreCase("greek")) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (orderType.equalsIgnoreCase("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }
        return pizza;
    }
}